package com.chixing.day03_oop;

import com.chixing.day02.SortUtil;

public class ProductTest {
    public static void main(String[] args) {
        Product product1 = new Product(2001,"苹果",25.1F,"烟台");
        Product product2 = new Product(2002,"香蕉",24.1F,"香港");
        Product product3 = new Product(2003,"菠萝",23.1F,"山东");
        Product product4 = new Product(2004,"西瓜",21.1F,"辽宁");
        Product product5 = new Product(2005,"水蜜桃",22.1F,"安徽");
        Product product6 = new Product(2006,"猕猴桃",300.1F,"陕西");
        Product product7 = new Product(2007,"大香蕉",27.1F,"山西");
        Product product8 = new Product(2008,"大西瓜",500.1F,"江苏");
        Product product9 = new Product(2009,"大苹果",26.1F,"上海");
        Product product10 = new Product(2010,"大菠萝",700.5F,"甘肃");
        Product[] arrProduct = {product1,product2,product3,product4,product5,product6,product7,product8,product9,product10};
        for (int i = 0; i < arrProduct.length ; i++) {
            System.out.println(arrProduct[i].getProId()+","+arrProduct[i].getProName());
        }
        System.out.println("============");
        for (int i = 0; i < arrProduct.length ; i++) {
            if(arrProduct[i].getProPrice()>300.0)
            System.out.println(arrProduct[i].getProName()+","+arrProduct[i].getProPrice()+"元");
        }
        System.out.println("============");
        Product temp = new Product();
        for (int i = 0; i < arrProduct.length; i++) {
            for (int j = i+1; j < arrProduct.length; j++) {
                if(arrProduct[i].getProPrice()>arrProduct[j].getProPrice()){
                    temp= arrProduct[i];
                    arrProduct[i]=arrProduct[j];
                    arrProduct[j]=temp;
                }
            }
        }
        for (int i = 0; i < arrProduct.length ; i++) {
            System.out.println(arrProduct[i].getProId()+","+arrProduct[i].getProName());
        }
    }
}
